package com.attilax.ui;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class SwtLauncher extends Shell {
	
	public SwtLauncher(){}
	public SwtLauncher(Display display) {
		super(display);
	}

	protected void threadRecycle(Display display, Shell shell) {
		//atiBrowserExampleinstance.gotoUrl();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
			{
				display.sleep();
				//System.out.println("----display.slee");
			}
		}
		// icon.dispose();
	//	atiBrowserExampleinstance.dispose();
		display.dispose();
		System.out.println("----display.dispose");
	}
	
	public void threadRecycle4swimg() {
		 final Display display=BrowserForm.display;
		 display.sleep();System.out.println("----display.slee222");
		aa(display);
	}
	private void aa(final Display display) {
		//if(!display.isDisposed()){
			Runnable runnable=new Runnable(){
			public void run(){
				while (!display.isDisposed()) {
					if (!display.readAndDispatch())
					{
						try {
							Thread.sleep(50);
						} catch (InterruptedException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						display.sleep();System.out.println("----display.slee222");
					}
				}
				// icon.dispose();
			//	atiBrowserExampleinstance.dispose();
			//	display.dispose();
			} 
		 	};
		 	runnable.run();
		//	display.syncExec(runnable);//关键在这一句上（同步调用，等待主界面线程处理完成之后）
			//}
		
				 //new Display();;
		//atiBrowserExampleinstance.gotoUrl();
		
		System.out.println("----display.dispose222");
	}
	
	protected void checkSubclass()  
    {  
          
    }  
}
